<template>
  <div class="radioItem">
    <div v-for="(item,index) of radioitem"
         :key="index"
         class="radio-item"
         @click="enterDetail(item.id)">
      <div class="left">
        <img :src="item.picUrl"
             @load="imgLoad"
             alt="">
      </div>
      <div class="rigth">
        <p class="name">{{item.name}}</p>
        <p class="desc">{{item.rcmdtext}}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'RadioItem',
  data () {
    return {
      imgCount: 0
    }
  },
  props: {
    radioitem: {
      type: Array,
      default () {
        return [];
      }
    }
  },
  methods: {
    // 图片加载,判断图片是否加载完毕
    imgLoad () {
      if (this.imgCount === this.radioitem.length) this.$emit("imgLoad");
      this.imgCount++;
    },
    // 电台详情
    enterDetail (id) {
      this.$router.push('/program/' + id);
    }
  }
}
</script>

<style scoped>
.radioItem {
  width: 100%;
  box-sizing: border-box;
  height: 450px;
  margin-top: 5px;
}
.radio-item {
  width: 50%;
  height: 200px;
  float: left;
  display: flex;
}
.radio-item .left {
  width: 32%;
  height: 100%;
  height: 100%;
}
.left img {
  width: 150px;
  height: 150px;
  margin: 10px;
}
.rigth {
  flex: 1;
  padding-top: 40px;
}
.rigth p {
  line-height: 30px;
}
.rigth .name {
  font-size: 18px;
}
.rigth .desc {
  font-size: 12px;
  color: #333;
}
</style>
